package com.lianzhihui.romeex.mvp.presenter;

import android.content.Context;

import com.lianzhihui.romeex.bean.UserInfoBean;
import com.lianzhihui.romeex.mvp.model.MainModelImp;
import com.lianzhihui.romeex.mvp.model.MainModelInterface;
import com.lianzhihui.romeex.mvp.view.MainActivityView;

//逻辑实现
public class MainPresnterImp implements MainModelInterface {

    private final MainActivityView viewLayer;
    private final MainModelImp modelImp;

    public MainPresnterImp(Context context, MainActivityView viewLayer) {
        this.viewLayer = viewLayer;
        modelImp = new MainModelImp(context, this);
    }

    /**
     * 获取 用户信息
     */
    public void requestUserInfo() {
        modelImp.requestUserInfo();
    }

    /**
     * 绑定邀请码
     *
     * @param inviteCode
     */
    public void requestBindParent(String inviteCode) {
        modelImp.requestBindParent(inviteCode);
    }


    @Override
    public void responseSuccess(UserInfoBean b) {
        viewLayer.responseUserSuccess(b);
    }

    @Override
    public void responseBindParentSuccess() {
        viewLayer.responseBindParentSuccess();
    }


    @Override
    public void onFailure() {
        viewLayer.setFailure();
    }
}
